﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{

    public class DSTVKPOSData : BaseVKPOSData
    {
        public bool checkVK07 = true;
        public DSTVKPOSData()
            : base()
        {

        }
        public DSTVKPOSData(OracleConnection _myConnection, IntexReptServBLClient _proxy, string userID = "        ")
            : base(_myConnection, _proxy, userID)
        {
        }
        public DSTVKPOSData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {

        }
        public string GetMemberV9(string company = "DST")
        {
            string memberv9 = "";
            try
            {
                OracleCommand or1;
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT HRMANDANT,HRBENID,HRPASSW,HRSPRKZ,HRVNAME,HRNNAME"
                +" FROM HRSTAMM "
                + "WHERE HRBGRP='V9' AND HRBERST=9";
                setResult = Connect2Proxy(or1);
                foreach (DataRow dwTemp in setResult.Tables[0].Rows)
                {
                    memberv9 += dwTemp["HRBENID"].ToString().Trim() + ";";
                } 
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return memberv9;
        }
        public string GetAdministration(string company = "DST")
        {
            string Administration = "";
            try
            {
                OracleCommand or1;
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT HRMANDANT,HRBENID,HRPASSW,HRSPRKZ,HRVNAME,HRNNAME"
                + " FROM HRSTAMM "
                + "WHERE HRSACHG like '%ADMINISTRATION%' AND HRBERST=9";
                setResult = Connect2Proxy(or1);
                foreach (DataRow dwTemp in setResult.Tables[0].Rows)
                {
                    Administration += dwTemp["HRBENID"].ToString().Trim() + ";";
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Administration;
        }
        public override DataSet GetData(DataRow dwUI)
        {
            base.GetData(dwUI);
            string progress = "查询完成";
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            DataSet setTXTKOPF = new DataSet();
            try
            {
                EventDispatcher.Instance.RaiseStatus("查询开始", StatusEventType.StartProgress);
                DataRow dwVKKOPF = dwUI;
                setResult = GetVKKOPF(dwVKKOPF);
                setReturn.Merge(setResult);
                setResult = GetDATALINK(dwVKKOPF);
                setReturn.Merge(setResult); 
                setReturn.Merge(GetVKPOS(dwVKKOPF));
                setReturn.Merge(QueryWDECK(dwVKKOPF));  
                EventDispatcher.Instance.RaiseStatus("查询完成", StatusEventType.StopProgress);
            }
            catch (Exception ex)
            {
                Tracer.Error(ABPOS + ex.StackTrace, ex);
            }
            finally
            {
                EventDispatcher.Instance.RaiseStatus("查询完成", StatusEventType.StopProgress);
            }
            return setReturn;
        }
    }
}